Skip to content

bpo-37851: faulthandler allocates its stack on demand#15358

Merged
vstinner merged 1 commit into
python:masterfrom
vstinner:faulthandler_alt_stack
Aug 21, 2019
Merged

bpo-37851: faulthandler allocates its stack on demand#15358
vstinner merged 1 commit into
python:masterfrom
vstinner:faulthandler_alt_stack

Conversation

@vstinner

@vstinner vstinner commented Aug 21, 2019

Copy link
Copy Markdown
Member

The faulthandler module no longer allocates its alternative stack at
Python startup. Now the stack is only allocated at the first
faulthandler usage.

faulthandler no longer ignores memory allocation failure when
allocation the stack. sigaltstack() failure now raises an OSError
exception, rather than being ignored.

Moreover, the alternative stack is no longer used if sigaction() is
not available. In practice, sigaltstack() should only be available
when sigaction() is avaialble, so this change should have no effect
in practice.

faulthandler.dump_traceback_later() internal locks are now only
allocated at the first dump_traceback_later() call, rather than
always being allocated at Python startup.

https://bugs.python.org/issue37851

The faulthandler module no longer allocates its alternative stack at
Python startup. Now the stack is only allocated at the first
faulthandler usage.

faulthandler no longer ignores memory allocation failure when
allocation the stack. sigaltstack() failure now raises an OSError
exception, rather than being ignored.

Moreover, the alternative stack is no longer used if sigaction() is
not available. In practice, sigaltstack() should only be available
when sigaction() is avaialble, so this change should have no effect
in practice.

faulthandler.dump_traceback_later() internal locks are now only
allocated at the first dump_traceback_later() call, rather than
always being allocated at Python startup.
@vstinner

Copy link
Copy Markdown
Member Author

Travis CI job failed with a network failure:

"E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/b/babeltrace/libbabeltrace1_1.3.2-1_amd64.deb Could not connect to apt.cache.travis-ci.com:80 (34.96.81.152), connection timed out"

I restarted the job.

@vstinner vstinner merged commit d8c5adf into python:master Aug 21, 2019
@vstinner vstinner deleted the faulthandler_alt_stack branch August 21, 2019 12:40
@tacaswell

Copy link
Copy Markdown
Contributor

This causes python to segfault with

import faulthandler
faulthandler.cancel_dump_traceback_later()

Also opening an issue on bpo.

Details used the following to bisect this:
make clean
make -j 8

./python -c "import faulthandler; faulthandler.cancel_dump_traceback_later()"
if [ $? -eq 139 ]; then
    echo "It crashed!"
    exit 1
fi

@tacaswell

Copy link
Copy Markdown
Contributor

lisroach pushed a commit to lisroach/cpython that referenced this pull request Sep 10, 2019
The faulthandler module no longer allocates its alternative stack at
Python startup. Now the stack is only allocated at the first
faulthandler usage.

faulthandler no longer ignores memory allocation failure when
allocating the stack. sigaltstack() failure now raises an OSError
exception, rather than being ignored.

The alternative stack is no longer used if sigaction() is
not available. In practice, sigaltstack() should only be available
when sigaction() is avaialble, so this change should have no effect
in practice.

faulthandler.dump_traceback_later() internal locks are now only
allocated at the first dump_traceback_later() call, rather than
always being allocated at Python startup.
DinoV pushed a commit to DinoV/cpython that referenced this pull request Jan 14, 2020
The faulthandler module no longer allocates its alternative stack at
Python startup. Now the stack is only allocated at the first
faulthandler usage.

faulthandler no longer ignores memory allocation failure when
allocating the stack. sigaltstack() failure now raises an OSError
exception, rather than being ignored.

The alternative stack is no longer used if sigaction() is
not available. In practice, sigaltstack() should only be available
when sigaction() is avaialble, so this change should have no effect
in practice.

faulthandler.dump_traceback_later() internal locks are now only
allocated at the first dump_traceback_later() call, rather than
always being allocated at Python startup.
websurfer5 pushed a commit to websurfer5/cpython that referenced this pull request Jul 20, 2020
The faulthandler module no longer allocates its alternative stack at
Python startup. Now the stack is only allocated at the first
faulthandler usage.

faulthandler no longer ignores memory allocation failure when
allocating the stack. sigaltstack() failure now raises an OSError
exception, rather than being ignored.

The alternative stack is no longer used if sigaction() is
not available. In practice, sigaltstack() should only be available
when sigaction() is avaialble, so this change should have no effect
in practice.

faulthandler.dump_traceback_later() internal locks are now only
allocated at the first dump_traceback_later() call, rather than
always being allocated at Python startup.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants